package com.kim.smartring.net.entity;

import org.json.JSONObject;

import android.content.Context;
import android.util.Log;

import com.kim.smartring.net.AEntity;
import com.kim.smartring.net.IReceiverListener;

/**
 * Title: XXXX (类或者接口名称) Description: XXXX (简单对此类或接口的名字进行描述) Copyright:
 * Copyright (c) 2008 Company:深圳彩讯科技有限公司
 * 
 * @author X
 * @version 1.0
 */
public abstract class BaseEntity extends AEntity {

	private static final String TAG = "BaseEntity";

	public static final String ERROR_BADDATAFORMAT = "响应数据非标准JSON格式！";
	public static final String ERROR_BADRETURNCODE = "获取响应码错误！";

	// 返回码
	public static final String RETURN_CODE = "code";
	// 成功返回码
	public static final String RETURN_CODE_SUCCESS = "S_OK";
	// 错误信息
	public static final String RETURN_ERROR_MSG = "summary";

	public JSONObject result; // 服务器返回的结果

	public boolean success = false; // 操作结果
	public String errorCode = ""; // 错误码
	public String errorMsg = "";
	public boolean needRefreshUI = false; // 是否需要刷新UI
	public Context context;

	public BaseEntity(Context context, IReceiverListener receiverListener) {
		super(receiverListener);
		this.context = context;
	}

	@Override
	public void decodeReceiveData() {
		if (receiveData == null) {
			return;
		}
		try {
			Log.d(TAG, String.format("response data:%s", receiveData));
			result = new JSONObject(receiveData);
		} catch (Exception e) {
			Log.d("BaseEntity", "decodeReceiveData error:" + e.getMessage());
		} finally {

		}
	}

	@Override
	protected void initHttpHeader() {
	}

	public JSONObject getResult() {
		return this.result;
	}

}
